package tt.dz.egobus.servicemanager.entities;

import org.hibernate.validator.constraints.NotBlank;
import tt.dz.egobus.base.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.Max;

/**
 * @author Anson
 * @date 17-3-14
 * @name 车型信息
 * @since 1.0.1
 */
@Entity
@Table(name = "bus_type", schema = "servicemanager")
public class BusType extends BaseEntity {

    private static final long serialVersionUID = -5838293365185781988L;
    /**
     * 品牌
     */
    @Column(length = 50)
    @NotBlank(message="车型不能为空")
    private String brand;

    /**
     * 型号
     */
    @Column(length = 25)
    private String version;

    /**
     * 车座
     */
    @Column(name = "seat_num")
    @Max(value=10000,message="座位数不能大于10000")
    private int seatNum;

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getVersion() {
        return version;
    }


    public void setVersion(String version) {
        this.version = version;
    }

    public int getSeatNum() {
        return seatNum;
    }

    public void setSeatNum(int seatNum) {
        this.seatNum = seatNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BusType)) return false;

        BusType busType = (BusType) o;

        if (getSeatNum() != busType.getSeatNum()) return false;
        if (getBrand() != null ? !getBrand().equals(busType.getBrand()) : busType.getBrand() != null) return false;
        return getVersion() != null ? getVersion().equals(busType.getVersion()) : busType.getVersion() == null;

    }

    @Override
    public int hashCode() {
        int result = getBrand() != null ? getBrand().hashCode() : 0;
        result = 31 * result + (getVersion() != null ? getVersion().hashCode() : 0);
        result = 31 * result + getSeatNum();
        return result;
    }

    @Override
    public String toString() {
        return "BusType{" +
                "brand='" + brand + '\'' +
                ", version='" + version + '\'' +
                ", seatNum=" + seatNum +
                '}';
    }
}
